<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const xhr = new XMLHttpRequest();

      console.log(xhr.readyState); //0 初始状态

      xhr.open("GET", "http://127.0.0.1:3000/mp4");

      console.log(xhr.readyState); //1 open 被调用

      xhr.onreadystatechange = function () {
        console.log(xhr.readyState);
      };

      // xhr.onprogress = function (e) {
      //   console.log(xhr.readyState, (e.loaded / e.total) * 100 + "%"); // 3 响应正在被加载  //4 请求完成
      // };
      // xhr.onload = function () {
      //   console.log(xhr.readyState); //4 请求完成
      // };
      // 发送请求
      xhr.send();
    </script>
  </body>
</html>
